require(['goSwiper'], function(goSwiper) {
	getData();
    function getData() {
        xget(
        	wxUrl + '/v3.2/farm/yellowPage/index', 
        	{
	            token: token,
	            lat: latitude,
	            lng: longitude,
	            province: province,
	            county: district
	        },
	        function(data) {
				$('.loading_modal').hide();
	            if (data.code != 0) {
					promptBox(data.msg);
	            } else {
	            	var result = data.data;
	                var html = _.template($('#wz_tpl').html(), result);
	                $('.wz_wrapperTop').html(html);
	                $('#wz_province').text(province);
	                $('#wz_district').text(district);
	                var swiper = new Swiper('.wz_swiper1', {
	                    pagination: '.wz_pagination1',
	                    paginationClickable: true,
	                    autoplayDisableOnInteraction: false,
	                    centeredSlides: true,
	                    loop: true
	                });
	                var swiper2 = new Swiper('.wz_swiper2', {
	                    pagination: '.wz_pagination2',
	                    paginationClickable: true,
	                    autoplayDisableOnInteraction: false,
	                    centeredSlides: true,
	                    loop: true
	                });
	                //最新农庄背景图
					$('.wz_newBigCtn').css({
                        'background' : 'url(' + result.newFarms[0].coverPic + ') 0% 50% / cover no-repeat',
                        'background-size' : 'cover'
                    });
	                //跳转到详情
	                $('.wz_toDetail').on('click', function() {
	                    var liId = $(this).attr('id');
	                    window.location.href = '../yellowPage/yellowPage_detail.html?id=' + liId;
	                });
	            }
        	}
	    );
    }
    //查看全部农庄
    $('#wz_seeAll').on('click', function() {
    	window.location.href = '../yellowPage/yellowPage_list.html';
    });
    //点击搜索
    $('#goSearch').on('click', function() {
    	window.location.href = '../yellowPage/farmSearch.html';
    });
});
// 为可控制返回指定页面所有添加pushState
history.pushState({}, document.title, null);
pushVHistory();
window.addEventListener("popstate", function() {
    // 跳转到订单列表页面
	goBackVHistory();
});